<include file="Common:pony" />
<body>
<include file="Common:sellerpanel" />
<h2>待处理订单</h2>
<form id="form1" name="form1" method="post" action="<{:U('tradesave')}>">
<table cellspacing="1" cellpadding="3" border="0">
<tr class="header">
<th width="120" align="center">订单号</th>
<th align="center">买家帐号</th>
<th>收货地址</th>
<th width="120">卖家备注<br>
  买家留言</th>
<th width="120">商品信息</th>
<th width="100" align="center">快递</th>
<th align="center">运单号</th>
<th align="center">订单金额<br>
  总成本</th>
<th align="center">提交时间</th>
<th align="center">待处理</th>
</tr>
<php>
if( $tradelist ) {
	
	foreach( $tradelist as $trade ) {
		$ordersinfo = '';
		$orders = unserialize( $trade['orders'] );		
		foreach(  $orders['order'] as $t=>$order ){
			$ordersinfo .= '<div>'. ($t+1).'.'. $order['outer_sku_id'] .'('.$order['num'] .'件)</div>';
		} 
		$company = D('Company')->where("id={$trade['syscomid']}")->getField('name');
		$tradeflag = tradeflag( $trade['seller_flag'] );
		echo '<tr class="row">
		<td height="50" align="center">'. strval($trade['tid']). '</td>
		<td align="center">'. $trade['buyer_nick'] .'<br>'. contacttuser( $trade['buyer_nick'] ) . '</td>
		<td>'. $trade['receiver_name'] .','. $trade['receiver_mobile'] . ','. $trade['receiver_phone'] .',' . $trade['receiver_state'] .', '. $trade['receiver_city']. ' '. $trade['receiver_district'] .','. $trade['receiver_address'] .','. $trade['receiver_zip'] . '</td>
		<td><span style="color:red">'. $tradeflag . ' '. $trade['seller_memo'] . '</span><br><span style="color:blue">' . $trade['buyer_message'] .'</span></td>
		<td>'. $ordersinfo .'</td>
		<td align="center">'. $company .'</td>
		<td align="center">'. $trade['out_sid'] .'</td>
		<td align="center">' .$trade['payment']. '/'. $trade['syscost'] .' </td>
		<td align="center">' .$trade['sysaddtime'] .' </td>';
		echo '<td align="center" width="70">';
		if( $tradefeedback  ) {
			echo '<img src="'. __PUBLIC__. '/images/talk_on.png" id="toTalk_'. strval($trade['tid']) .'" style="cursor:pointer" alt="'. strval($trade['tid']) .'" title="'. U("Index/tradefeedback?tid={$trade['tid']}") .'" />';
		} else {
			echo '<img src="'. __PUBLIC__. '/images/talk_off.png" id="toTalk_'. strval($trade['tid']) .'" style="cursor:pointer" alt="'. strval($trade['tid']) .'" title="'. U("Index/tradefeedback?tid={$trade['tid']}") .'" />';
		}
		echo '&nbsp;&nbsp;';
		if( $trade[systodo] ) {
			echo '<img src="'. __PUBLIC__. '/images/do_on.png" id="todo_'. strval($trade['tid']) .'" style="cursor:pointer"  alt="'. strval($trade['tid']) .'" />';
		}else {
			echo '<img src="'. __PUBLIC__. '/images/do_off.png" id="todo_'. strval($trade['tid']) .'" style="cursor:pointer" alt="'. strval($trade['tid']) .'" />';
		}
		echo '</td></tr>';
		
	} 
}
</php>
<tr>
<td colspan="10" height="30" align="center"><div><{$page}></div></td>
</tr>
</table>

<script>
$(document).ready(function(){
	$("select[id^='company_']").bind('change', function(){
		var tplid = $(this).val();
		var tid   = $(this).attr( 'alt' );
		$.post ( '<{:U('Index/price')}>', { trade : $("#tradedata_" + tid ).val() , tplid: tplid }  ,
			function(data){
				if( 1 == data['status'] ) {
					$('#chengben_'+tid).html( data['data']['cost'] );	
				} else {
					alert( data['info']);
				}
			 	
			}	
		); 
	});
	
	
	$("img[id^='todo_']").bind( 'click', function() {
		var tid = $(this).attr( 'alt' );
		var _this  = $(this);
		$.post( '<{:U('Index/tradetodo')}>' , {
			tid : tid
		}, 
		function(data){
			if( 1 == data['status'] ){
				if( 1 == data['data'] ) {
					_this.get(0).src ='<{:__PUBLIC__}>/images/do_on.png';
				}else {
					_this.get(0).src ='<{:__PUBLIC__}>/images/do_off.png';
				}
				//alert( data['info'] );
				//_this.attr('disabled', 'disabled');
			}else {
				alert('提交失败 '+ data['info'] );	
			}
			
		} 
	);
	} );
	
	$("img[id^='toTalk_']").bind( 'click', function(){
		
		var _this = $(this);
		var tid = _this.attr('alt');
		var url = _this.attr('title');
		
		art.dialog.open( url , {
			id: 'fedbbackID',
		    title: '待处理',
		    yesFn: function(){
		    },
		    noFn: function(){
		    }
		});
		
	} )
	
	
	$("input[id^='btnCanceltodo_']").bind('click', function(){
		var tid = $(this).attr( 'alt' );
		if(window.confirm('真的要取消处理？')){
			$.post('<{:U('Index/tradefeedbackcancel')}>' , {
				tid : tid
				
			} , function(data){
				if( 1 == data['status'] ){
					alert( data['info'] );
				}else {
					alert('提交失败 '+ data['info'] );	
				}
			} );
			
		}
		
	});
	
	
});
</script>
</body>
</html>